package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.impl.StudentDaoImpl;
import pojo.Student;

@WebServlet("/checkUser")
public class CheckUserServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		StudentDaoImpl studentDao=new StudentDaoImpl();
		String sno=request.getParameter("sno");
		Student student=studentDao.findStudentByNum(sno);
		response.setContentType("text/html; charset=utf-8");
		if(student!=null){
			response.getWriter().println("该学号不可用！");			//输出检测结果
		}else{
			response.getWriter().println("恭喜，该学号可用！");			//输出检测结果
		}

	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
